package com.tencent.hummingbird.portal.mapper;

import com.tencent.hummingbird.portal.pojo.Answer;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
* <p>
    *  Mapper 接口
    * </p>
*
* @author yxb
* @since 2024-01-10
*/
@Repository
public interface AnswerMapper extends BaseMapper<Answer> {
    List<Answer> findAnswersWithCommentByQuestionId(Integer questionId);

    @Select("SELECT COUNT(*)\n" +
            "\tFROM answer\n" +
            "\tWHERE quest_id = #{id}")
    Integer countAnswerByQuestionId(Integer id);

    @Update("update answer set accept_status=#{acceptStatus}" +
            " where id=#{answerId}")
    int updateAcceptStatus(@Param("answerId") Integer answerId,
                           @Param("acceptStatus") Integer acceptStatus);
}
